<template>
<div>
  <v-top></v-top>
  <v-nav></v-nav>
  <v-module>
    <slot>


<div class='mv'>
<!--      左边部分-->
  <div class='left'>
<!--    标题-->
    <div class='title'>
      <a href=''></a>
      <h2>{{data.name}}</h2>
      <a style='color: #0c73c2' href=''>{{name[0]}}</a>
      <a v-if='name.length === 2 '  style='color: #0c73c2' href=''>
/{{name[1]}}
      </a>
    </div>
<!--    视频-->
    <div class='video'>
      <video style="background:black;border:none" controls autoplay preload width='640' height='360' :src='mvurl'></video>
    </div>
<!--    按钮-->
    <div class='btn'>
      <a href=''>
        <i>
          <em></em>
          ({{msg.likedCount}})
        </i>
      </a>
      <a href=''>
        <i>
          ({{data.subCount}})
        </i>
      </a>
      <a href=''>
        <i>
          ( {{data.shareCount}} )
        </i>
      </a>
    </div>
<!--    评论区-->
    <v-comment :commentCount='data.commentCount'></v-comment>
  </div>
  <!--      右边部分-->
  <div class='right'>
    <h3>mv简介</h3>
    <div class='introduce'>
      <p style='color: #999'>发布时间：{{data.publishTime}}</p>
      <p style='color: #999'>播放次数：{{ (data.playCount / 10000).toFixed(2)}}万次</p>
      <p style='margin-top: 10px'>   {{data.desc}}{{data.briefDesc}}</p>
    </div>
    <h3 style='margin-top: 20px;'>相关推荐</h3>
    <ul class='recommendation'>
      <li v-for='(item,index) in recommendation'>
          <div class='recommendation-left'>
            <img width='96' height='54' :src='item.coverUrl' alt=''>
            <p>

              <span></span>
              {{ (item.playTime/10000).toFixed(2)}}万
            </p>
          </div>
        <div class='recommendation-right'>
          <router-link :to="'/video/' + item.vid">
            <p>{{item.title}}</p>
          </router-link>
          <p style='color:#999;'>{{ mvtime[index]}}</p>
          <p style='color:#999;;'>
            by
            <router-link :to="'/user/'+ item.creator[0].userId">
              <a href='' style='color:#999;'>{{ item.creator[0].userName }}</a>
            </router-link>
          </p>
        </div>
      </li>
    </ul>
  </div>
</div>
    </slot>
  </v-module>
</div>
</template>
<script>
import axios from 'axios'
import Top from '@/views/Top/Top'
import Nav from '@/views/Nav/Nav'
import module from '@/views/Module/module'
import config from '@/network/config'
import Comment from '@/views/Mv/Comment/Comment'
import moment from 'moment'
export default {
  name: 'Mv',
  components:{
    "v-top":Top,
    'v-nav':Nav,
    'v-module':module,
    'v-comment':Comment
  },
  data(){
    return{
      mvurl:'',
      url:config.url,
      data:[],
      name:[],
      recommendation:[], //相关推荐
      msg:'', //点赞数,
      mvtime:[]
    }
  },
  methods:{
    getmv(){
      axios.get(`${this.url}/mv/url?`,{
        params:{
          id:this.$route.params.id
        }
      }).then(res => {
        this.mvurl = res.data.data.url;
      })
    },//获取mv链接
    async commenton(){
     let data = await axios.get(`${this.url}/mv/detail?mvid=${this.$route.params.id}`)
    this.data = data.data.data
    var name  = data.data.data.artists   //获取名字
    if(name.length === 1){
      this.name.push(name[0].name)
    } else if(name.length === 2){
      this.name.push(name[0].name,name[1].name)
    }
  },    //获取mv数据



    async commendation(){
     let data = await axios.get(`${this.url}/related/allvideo?id=${this.$route.params.id}`)
      var list = []
      data.data.data.forEach(item => {
        list.push(item.durationms)
      }) //获取mv时间
      for (let i = 0; i < 5; i++) {
        this.mvtime.push(moment(list[i]).format('mm:ss'))
      }
      this.recommendation = data.data.data;
    },//相关推荐的数据




    getmsg(){
      axios.get(`${this.url}/mv/detail/info?mvid=${this.$route.params.id}`).then(res => {
       this.msg = res.data
      })
    },  //获取点赞数等
  },
  mounted(){
    this.getmv()    //mv url
    this.commenton()   //mv 详情
    this.commendation() //相关推荐
    this.getmsg()//获取点赞数等
  }
}
</script>
<style scoped>

.recommendation-right p{
  display:block;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.recommendation-right{
  display: flex;
  flex-direction:column;
  justify-content: center;
  margin-left: 10px;
  overflow: hidden;

}
.recommendation-left{
  position:relative;
}
.recommendation-left p{

  position: absolute;
  display: flex;
  align-items: center;
  right: 0;
  justify-content: space-evenly;
  top: 0;
  color: white !important;
  text-shadow: -2px 1px rgb(0 0 0 / 40%);
  background: url("../../assets/images/mask.png");
  height: 20px;
  width: 90px;
  padding-right: 5px;
  line-height: 20px;
  box-sizing: border-box;
  text-align: right;
}
.recommendation-left p span{
  width: 15px;
  height: 10px;
  background: url("../../assets/images/icon2.png") -60px -310px;
  color: white;
}
.recommendation li{
  display: flex;
  height: 54px;
  margin-top: 10px;
}

/*相关推荐*/
.introduce p{
  text-align: justify !important;
}
.right p{
  color: #333;
  font-size: 12px;
  line-height: 18px;
}
.right h3{
  height: 23px;
  margin-bottom: 20px;
  border-bottom: 1px solid #ccc;
  font-size: 12px;
  font-style: normal;
  color: #333;
  font-weight: 300px;
}
.right{
  box-sizing: border-box;
}
/*右边 */
.btn a  em{
  display: block;
  background: url("../../assets/images/button2.png");
  width: 17px;
  height: 15px;
  margin: 8px 6px 0 0;
}



.btn a:nth-child(1) i em{
  background-position: 0 -95px !important;
}


.btn a:nth-child(1){
  background-position: right -100px!important;
  color: #333;
}
.btn a:nth-child(1) i{
  display: flex;
  background-position: 0 -59px !important;
}

.btn a:nth-child(2){
  background-position: right -100px!important;
  color: #333;
}
.btn a:nth-child(2) i{
  padding-right: 2px;
  padding-left: 28px;
  display: flex;
  background-position: 0 -977px;
}

.btn a:nth-child(3){
  background-position: right -100px!important;
  color: #333;
}
.btn a:nth-child(3) i{
  padding-right: 2px;
  padding-left: 28px;
  display: flex;
  background-position: 0 -1268px;
}

.btn > a i{
  background: url("../../assets/images/button2.png");
  padding: 0 5px 0 10px;
  display: inline-block;
  *display: inline;
  *zoom: 1;
  height: 31px;
  line-height: 31px;
  overflow: hidden;
  *line-height: 32px;
  vertical-align: top;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  font-style: normal;
}
.btn > a {
  background: url("../../assets/images/button2.png");
  padding: 0 5px 0 0;
  display: inline-block;
  *display: inline;
  *zoom: 1;
  height: 31px;
  line-height: 31px;
  overflow: hidden;
  *line-height: 32px;
  vertical-align: top;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  margin-right: 10px;
}
.btn{
  margin-top: 10px;
}
/*按钮*/

.title h2{
  font-size: 24px;
  max-width: 100%;
  margin-top: -10px;
  margin-right: 8px;
  line-height: 32px;
  font-weight: normal;
}
.title{
  display: flex;
  padding-top: 10px;
  margin-bottom: 8px;
  align-items: center;
}
.title a:hover{
  text-decoration: underline;
}
.left .title a:nth-child(1){
  display: block;
  width: 29px;
  height: 18px;
  background: url("../../assets/images/icon2.png")-230px -480px;
  margin-bottom: 5px;
  margin-right: 4px;
}


.right{
  width: 270px;
  padding: 20px 40px 40px 30px;
  border-left: 1px solid #eee;
}
.mv{
  width: 100%;
  height: 100%;
  display: flex;
}
.left{
  padding: 30px 30px 40px 39px;
}
</style>